<template>
	<slot :controller="controller" :store="store" :model="model">
    <AppForm
		ref="editForm"
        v-bind="$attrs"
		:id="controlID"
		:name="model.codeName"
		:class="classNames"
		:data="store.data"
		>
        <AppAnchor v-if="store.anchorData.length > 0" :controlID="controlID" :anchorData="store.anchorData" />
		<a-row class="control-content app-control-form__content">
			<slot  name="MainPage" :controller="controller" :store="store" :model="model">
				<a-tabs class="app-control-form__page">
					<slot name="formpage1" :controller="controller" :store="store" :model="model">
					    <a-tab-pane 
					        class="app-control-form__page "
					        v-show="store.detailModel.formpage1.visible"
					        key="formpage1">
					        <template #tab>
					            <slot name="formpage1Title" :controller="controller" :store="store" :model="model">
					                <AppIconText text="基本信息"/>
					            </slot>
					        </template>
					        <slot name="formpage1Content" :controller="controller" :store="store" :model="model">
					            <AppFormPage :layoutOpts="{selfLayout: 'TABLE_24COL',}">
					                    <AppCol
					                        noRoot
					                        :visible="store.detailModel.group1.visible"
					                        :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}">
					                        <template #default="{ slotClass, slotStyle }">
					                            <slot name="group1" :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
					                                <AppFormGroup 
					                                    name="group1"
					                                    v-show="store.detailModel.group1.visible"
					                                    :slotClass="slotClass"
					                                    :slotStyle="slotStyle"
					                                    :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}"
					                                    :title="$t('CONTROL.DEFORM.AVUECHILDFIVE.MAIN.GROUPPANEL.GROUP1', 'avue示例实体05基本信息')"
					                                    subCaption=""
					                                    :enableAnchor="false"
					                                    :showMoreItems="store.detailModel.group1.showMoreItems"
					                                    :showMoreMode="store.detailModel.group1.showMoreMode"
					                                    :infoGroupMode="false"
					                                    :titleBarCloseMode="0"
					                                    :showCaption="true"
					                                    :uIActionGroup="store.detailModel.group1.uIActionGroup"
					                                    @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }">
					                                    <AppCol
					                                        noRoot
					                                        :visible="store.detailModel.avuechildfivename.visible"
					                                        :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 24,}">
					                                        <template v-slot:default="{ slotStyle, slotClass }">
					                                            <slot name="avuechildfivename"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
					                                                <AppFormItem 
					                                                    name="avuechildfivename"
					                                                    :slotStyle="slotStyle"
					                                                    :slotClass="slotClass" 
					                                                    :label="$t('DEF.LNAME.AVUECHILDFIVE.AVUECHILDFIVENAME', 'avue示例实体05名称')"
					                                                    labelPos="LEFT" 
					                                                    :labelWidth="130" 
					                                                    :showLabel="true"
					                                                    :enableAnchor="false" 
					                                                    :rules="store.detailModel.avuechildfivename.valueRule"
					                                                    :emptyCaption="false">
					                                                    <div class="form-editor-container">
					                                                        <slot name="avuechildfivenameEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
					                                                            <AppInput
					                                                                v-bind="{ editorType: 'TEXTBOX', }"
					                                                                type="text"
					                                                                style=""
					                                                                name="avuechildfivename"
					                                                                :isDebounce="false"
					                                                                :disabled="store.detailModel.avuechildfivename.disabled"
					                                                                :value="store.data.avuechildfivename"
					                                                                @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
					                                                            />
					                                                        </slot>
					                                                    </div>
					                                                </AppFormItem>
					                                            </slot>
					                                        </template>
					                                    </AppCol>
					                                    <AppCol
					                                        noRoot
					                                        :visible="store.detailModel.avuetestname.visible"
					                                        :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 24,}">
					                                        <template v-slot:default="{ slotStyle, slotClass }">
					                                            <slot name="avuetestname"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
					                                                <AppFormItem 
					                                                    name="avuetestname"
					                                                    :slotStyle="slotStyle"
					                                                    :slotClass="slotClass" 
					                                                    label="avue测试名称"
					                                                    labelPos="LEFT" 
					                                                    :labelWidth="130" 
					                                                    :showLabel="true"
					                                                    :enableAnchor="false" 
					                                                    :rules="store.detailModel.avuetestname.valueRule"
					                                                    :emptyCaption="false">
					                                                    <div class="form-editor-container">
					                                                        <slot name="avuetestnameEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
					                                                            <AppDataPicker
					                                                                valueItem="avuechildfiveid"
					                                                                :context="store.context"
					                                                                :viewParams="store.viewParams"
					                                                                deMajorField="avuetestname"
					                                                                deKeyField="avuetestid"
					                                                                pickUpView="avueTestPickupView"
					                                                                deCodeName="AVUETEST"
					                                                                :acParams="{ serviceName: 'AvueTest', interfaceName: 'FetchDefault' }"
					                                                                v-bind="{ editorType: 'PICKER', AC: 'TRUE', PICKUPVIEW: 'TRUE' }"
					                                                                style=""
					                                                                name="avuetestname"
					                                                                :disabled="store.detailModel.avuetestname.disabled"
					                                                                :data="store.data"
					                                                                :value="store.data.avuetestname"
					                                                                @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
					                                                            />
					                                                        </slot>
					                                                    </div>
					                                                </AppFormItem>
					                                            </slot>
					                                        </template>
					                                    </AppCol>
					                                </AppFormGroup>
					                            </slot>
					                        </template>
					                    </AppCol>
					            </AppFormPage>
					        </slot>
					    </a-tab-pane>
					</slot>
					<slot name="formpage2" :controller="controller" :store="store" :model="model">
					    <a-tab-pane 
					        class="app-control-form__page "
					        v-show="store.detailModel.formpage2.visible"
					        key="formpage2">
					        <template #tab>
					            <slot name="formpage2Title" :controller="controller" :store="store" :model="model">
					                <AppIconText text="下拉树测试"/>
					            </slot>
					        </template>
					        <slot name="formpage2Content" :controller="controller" :store="store" :model="model">
					            <AppFormPage :layoutOpts="{selfLayout: 'TABLE_24COL',}">
					                    <AppCol
					                        noRoot
					                        :visible="store.detailModel.group2.visible"
					                        :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}">
					                        <template #default="{ slotClass, slotStyle }">
					                            <slot name="group2" :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
					                                <AppFormGroup 
					                                    name="group2"
					                                    v-show="store.detailModel.group2.visible"
					                                    :slotClass="slotClass"
					                                    :slotStyle="slotStyle"
					                                    :layoutOpts="{selfLayout: 'TABLE_24COL',parentLayout: 'TABLE_24COL',colMD: 24,}"
					                                    :title="$t('CONTROL.DEFORM.AVUECHILDFIVE.MAIN.GROUPPANEL.GROUP2', '操作信息')"
					                                    subCaption=""
					                                    :enableAnchor="false"
					                                    :showMoreItems="store.detailModel.group2.showMoreItems"
					                                    :showMoreMode="store.detailModel.group2.showMoreMode"
					                                    :infoGroupMode="false"
					                                    :titleBarCloseMode="0"
					                                    :showCaption="true"
					                                    :uIActionGroup="store.detailModel.group2.uIActionGroup"
					                                    @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }">
					                                    <AppCol
					                                        noRoot
					                                        :visible="store.detailModel.formitem.visible"
					                                        :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 24,}">
					                                        <template v-slot:default="{ slotStyle, slotClass }">
					                                            <slot name="formitem"  :controller="controller" :store="store" :model="model" :slotClass="slotClass" :slotStyle="slotStyle" :actions="{ handleComponentAction }">
					                                                <AppFormItem 
					                                                    name="formitem"
					                                                    :slotStyle="slotStyle"
					                                                    :slotClass="slotClass" 
					                                                    label="下拉树"
					                                                    labelPos="LEFT" 
					                                                    :labelWidth="130" 
					                                                    :showLabel="true"
					                                                    :enableAnchor="false" 
					                                                    :rules="store.detailModel.formitem.valueRule"
					                                                    :emptyCaption="false">
					                                                    <div class="form-editor-container">
					                                                        <slot name="formitemEditor"  :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
					                                                            <AppCustomDropdownList
					                                                                v-bind="{ editorType: 'DROPDOWNLIST', editorStyle: 'TREEDROPDOWNLIST', multiple: true, urlParams: {'testparam':'%param%'}, url: '/ibizappextendeditors/fetchdefault', fieldMap: {value:'value',label:'label',options:'children',pid:'pid'}, filterMap: {'selected-orgid':'value'}, method: 'get' }"
					                                                                :context="store.context"
					                                                                :viewParams="store.viewParams"
					                                                                style=""
					                                                                name="formitem"
					                                                                :disabled="store.detailModel.formitem.disabled"
					                                                                :value="store.data.formitem"
					                                                                :data="store.data"
					                                                                @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
					                                                            />                    </slot>
					                                                    </div>
					                                                </AppFormItem>
					                                            </slot>
					                                        </template>
					                                    </AppCol>
					                                    <AppCol
					                                        noRoot
					                                        :visible="store.detailModel.button1.visible"
					                                        :layoutOpts="{parentLayout: 'TABLE_24COL',colMD: 24,}">
					                                        <slot name="button1" :controller="controller" :store="store" :model="model" :actions="{ handleComponentAction }">
					                                            <AppFormButton
					                                            name="button1"
					                                            :disabled="store.detailModel.button1.disabled"
					                                            :showCaption="true"
					                                            :caption="$t('TBB.TEXT.*.SAVE', '保存')"
					                                            :uIAction="store.detailModel.button1.uIAction"
					                                            @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }"
					                                            />
					                                        </slot>
					                                    </AppCol>
					                                </AppFormGroup>
					                            </slot>
					                        </template>
					                    </AppCol>
					            </AppFormPage>
					        </slot>
					    </a-tab-pane>
					</slot>
				</a-tabs>
			</slot>
		</a-row>
    </AppForm>
	</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@FORM}}-form/{{spinalCase ctrl.codeName}}-form-base.vue.hbs生成

import { Ref } from 'vue';
import { AppAnchor } from '@components/common/anchor';
import { AppCol } from '@/components/common/col';
import { AppRow } from '@/components/common/row';
import { AppForm, AppFormPage, AppFormGroup, AppFormTabPage, AppFormItem, AppFormButton, AppFormDruipart, AppFormIframe, AppFormRaw, AppFormMdCtrl, AppFormMdCtrlRepeater } from '@components/widgets/form';
import { IEvent, EditFormActionType, IEditFormAbility, IEditFormStore, IParam } from '@/core';
import { useProps, useBasic, useAction, useController } from './main-form-hook';

const editForm: Ref = ref(null);

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { controlID, getClassNames, model ,useNavParamsBind, useEventBind, handleActionClick, handleComponentAction } = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: EditFormActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IEditFormAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
  return getClassNames(props);
});

//  表单控制器
const controller = useController(props, evt, { controlID, editForm });

useNavParamsBind(controller, props);

const store: IEditFormStore = controller.getStore();

const ctrlService = controller.getCtrlService();

onMounted(() => {
    controller.ctrlMounted();
});
onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>